package com.ithemai;

import java.io.*;
import java.util.ArrayList;
import java.util.List;

/**
 * @auther Macrydy
 * @date 2020/7/4 15:33
 */
public class Demo2 {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        List<Student> list = new ArrayList<>();
        list.add(new Student("张三",20));
        list.add(new Student("李四",25));

        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("a.txt"));
        oos.writeObject(list);
        oos.close();

        ObjectInputStream ois = new ObjectInputStream(new FileInputStream("a.txt"));
        Object o = ois.readObject();
        System.out.println(o);
        ois.close();
    }
}
